
//---------------------------------------------------------------------------
#include "rendering/pg2_window.h"
//---------------------------------------------------------------------------
using namespace pg2;
//---------------------------------------------------------------------------
bool Window::create (HINSTANCE hInstance, unsigned int uiWidth, unsigned int uiHeight)
{
	WNDCLASS kWC;

	memset( static_cast <void *> (&kWC), 0, sizeof(WNDCLASS) );

	kWC.style = CS_HREDRAW | CS_VREDRAW;
	kWC.lpfnWndProc = (WNDPROC)wndProc;
	kWC.hInstance = hInstance;
	kWC.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
	kWC.lpszClassName = "PG2 Engine";

	if( !RegisterClass(&kWC) )
	{
		return false;
	}

	// create window
	m_hWnd = CreateWindow(
						  "PG2 Engine",
						  "",
						  WS_OVERLAPPEDWINDOW,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  uiWidth + 8,
						  uiHeight + 30,
						  NULL,
						  NULL,
						  hInstance,
						  NULL
						  );

	if (!m_hWnd)
	{
		return false;
	}

	// show
	ShowWindow(m_hWnd, SW_SHOW);
	UpdateWindow(m_hWnd);

	return true;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK Window::wndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message) 
	{
		case WM_DESTROY:
		{
			PostQuitMessage(0);
			break;
		}
	}

	return DefWindowProc(hWnd, message, wParam, lParam);
}
//---------------------------------------------------------------------------
